"use strict";
/**
 * @author zhaojiuyi
 * @date 2022/9/28-15:17
 * @version 1.0.0
 */
import {doctorRouter} from "@/router/modules/doctor";
import {historyRouter} from "@/router/modules/hospital";
import {routerSplice} from "@/router/admin";
import {homePageRouter} from "@/router/admin";
import {adminBeforeEnter} from "./admin";
export default {
  setAdminRouter(_this){
    const newRouter = _this.$store.state.identity === 2? doctorRouter:_this.$store.state.identity === 3?historyRouter:[]
    if (newRouter.length){
      const homePage = _this.$util.deepClone(homePageRouter)
      const navList = _this.$util.deepClone(newRouter)
      homePage.redirect = navList[0].path
      homePage.beforeEnter = adminBeforeEnter
      homePage.children = navList
      const route = routerSplice("/admin",[homePage])
      _this.$store.commit("setAdminRouter",route[0].children)
      _this.$router.addRoute(route[0])
      _this.$router.options.routes.push(route[0])
    }
  }
}
